How to mod IDLE Adding a horizontal scrollbar

by: superpower!, 7 years ago


Since I've started using IDLE to program in Python, I have always wanted IDLE to have a horizontal scrollbar. But only recently I have figured out how to do this.

In this example, we will add a horizontal scrollbar.

First, go to your Python folder. Mine is here: C:UsersMSI_PCAppDataLocalProgramsPythonPython36

Then, go to Lib/idlelib.

Open up editor.py
You may want to backup this file just in case.

After, find this line of code:
self.vbar = vbar = Scrollbar(text_frame, name='vbar')

For me, it's at line 110.

Add this line after it:
self.hbar = hbar = Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)


Then, find this line:
vbar['command'] = text.yview

For me, it's at line 189.

Add this line after it:
hbar['command'] = text.xview


Then, find this line:
vbar.pack(side=RIGHT, fill=Y)
(It should be the next line)

Next, add this line after it:
hbar['command'] = text.xview


Then, find this line:
text['yscrollcommand'] = vbar.set
(It should be the next line)

And finally, add this line after it:
text['xscrollcommand'] = hbar.set


Test it out by opening another instance of IDLE.
If it didn't work post a comment and don't forget about your backup file if you need it.



You must be logged in to post. Please login or register an account.